<template>
  <div class="page" style="">
    <div class="print_title">任务委托详情 · 禾美环保</div>
    <p class="title">基本信息</p>
    <a-row type="flex" justify="start" class="content" style="padding: 0 9px;">
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">单据编号:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.billNo }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row>
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">申请人:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ filterMultiDictText(this.dictOptions['createBy'],
              formData.createBy + '') }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">

          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">申请部门:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ filterMultiDictText(this.dictOptions['sysOrgCode'],
              formData.sysOrgCode + '') }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">申请时间:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.createTime }}</p>
          </a-col>
        </a-row>
      </a-col>
    </a-row>

    <p class="title" style="margin-top: 18px;">项目信息</p>
    <a-row type="flex" justify="start" class="content" style="padding: 0 9px;">
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">项目名称:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.projectName }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">项目编号:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.finalNo }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">经营团队:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ filterMultiDictText(this.dictOptions['teamName'],
              formData.teamName + '') }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">项目承接人:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ filterMultiDictText(this.dictOptions['undertaker'],
              formData.undertaker + '') }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">立项日期:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.projectEstablishDate }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">签订单位:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ filterMultiDictText(this.dictOptions['signUnit'],
              formData.signUnit + '') }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">业绩归属年度:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.year }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">业主单位:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ filterMultiDictText(this.dictOptions['ownerUnit'],
              formData.ownerUnit + '') }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">联系人:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ filterMultiDictText(this.dictOptions['contacts'],
              formData.contacts + '') }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">联系方式:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.contactTel }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">项目所在地址:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ getAddress(formData.areaCode) }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">项目详细地址:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.projectAddress }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">项目来源:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{
              filterMultiDictText(this.dictOptions['projectSource'],
              formData.projectSource + '') }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">预计合同额(元):</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.estimatedContractAmount }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">预计合同额大写:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.estimatedContractcapitalChineseAmount }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="24">
        <a-row>
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">立项事由及说明:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.establishReason }}</p>
          </a-col>
        </a-row>
      </a-col>
    </a-row>

    <p class="title" style="margin-top: 18px;">任务信息</p>
    <a-row type="flex" justify="start" class="content" style="padding: 0 9px;">
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">任务编号:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.taskNo }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">业务分类:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.categoryName }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">合同占比(%):</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.contractRate }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">合同分配额(元):</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.contractAmount }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">切割合同额(元):</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.cutContractAmount }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">生产团队:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ filterMultiDictText(this.dictOptions['productTeam'],
              formData.productTeam + '') }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">任务类型:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ filterMultiDictText(this.dictOptions['taskType'],
              formData.taskType + '') }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">实施部门:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{
              filterMultiDictText(this.dictOptions['executeDepart'],
              formData.executeDepart + '') }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">部门负责人:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ filterMultiDictText(this.dictOptions['minister'],
              formData.minister + '') }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">项目负责人:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{
              filterMultiDictText(this.dictOptions['projectLeading'],
              formData.projectLeading + '') }}</p>
          </a-col>
        </a-row>
      </a-col>

      <!-- 环保咨询类 -->
      <template v-if="formData.taskType == 1 || formData.taskType == 4">
        <a-col :span="12" v-if="formData.taskType == 1">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">审核工程师:</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{
                filterMultiDictText(this.dictOptions['approvalEngineer'], formData.approvalEngineer + '') }}</p>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">审批级别:</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{
                filterMultiDictText(this.dictOptions['approvalLevel'], formData.approvalLevel + '') }}</p>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">审批系数:</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.approvalCoefficient }}</p>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">行业类别:</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{
                filterMultiDictText(this.dictOptions['industryCategory'], formData.industryCategory + '') }}</p>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">行业系数:</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.industryCoefficient }}</p>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">复杂程度:</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{ filterMultiDictText(this.dictOptions['complexity'],
                formData.complexity + '') }}</p>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">复杂系数:</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.complexCoefficient }}</p>
            </a-col>
          </a-row>
        </a-col>
      </template>
      <!-- 检验检测类 -->
      <template v-if="formData.taskType == 2">
        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">是否出具报告:</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{
                filterMultiDictText(this.dictOptions['isOutReport'],
                formData.isOutReport + '') }}</p>
            </a-col>
          </a-row>
        </a-col>

        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">费用核算方式:</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{
                filterMultiDictText(this.dictOptions['expenseAccountingMethod'], formData.expenseAccountingMethod + '')
                }}
              </p>
            </a-col>
          </a-row>
        </a-col>
      </template>

      <a-col :span="24">
        <a-row>
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">说明:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.instruction }}</p>
          </a-col>
        </a-row>
      </a-col>
    </a-row>
    <template v-if="formData.distributionDtList && formData.distributionDtList.length > 0">
      <p class="title" style="margin-top: 18px;">项目成员</p>
      <a-row type="flex" justify="center">
        <a-col :span="24">
          <a-table :columns="columns" :data-source="formData.distributionDtList" bordered :pagination="false"
            size="small" :rowClassName="tableRowClass"></a-table>
        </a-col>
      </a-row>
    </template>

    <template v-if="isShowProjectPay">
      <p class="title" style="margin-top: 18px;">项目预算</p>
      <a-row type="flex" justify="start">
        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">预算总工时(人小时):</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.expectWorkTime }}</p>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">生产总绩效(元):</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.totalProductPerformance }}</p>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">人工总成本(元):</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.workCost }}</p>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">委外费(元):</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.outsourcingFee }}</p>
            </a-col>
          </a-row>
        </a-col>

        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">差旅费(元):</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.travelFee }}</p>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">专家评审费(元):</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.professionReviewFee }}</p>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">其他成本(元):</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.otherCost }}</p>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="12">
          <a-row style="margin-bottom: 0">
            <a-col style="display: flex;">
              <p style="margin-bottom: 0; white-space: nowrap">项目预算合计(元):</p>
              <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.totalProjectBudget }}</p>
            </a-col>
          </a-row>
        </a-col>
      </a-row>
    </template>
    <template v-if="isShowProjectPay && formData.categoryName">
      <FileInfor :purchaseFile="projectBudgetFile"
        v-if="isProjectInformation && projectBudgetFile && projectBudgetFile.length" title="项目预算表"></FileInfor>
      <FileInfor :purchaseFile="productBudgetFile"
        v-if="!isProjectInformation && productBudgetFile && productBudgetFile.length" title="生产绩效表"></FileInfor>
    </template>
    <p class="title" style="margin-top: 18px;" v-if="templateDataList && templateDataList.length">任务进度</p>
    <a-row type="flex" justify="start" v-if="templateDataList && templateDataList.length">
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">进度模板:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.templateName }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">允许添加子节点:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.isAddChildNode == '1' ? '是' : formData.isAddChildNode == '0' ? '否' : '' }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row style="margin-bottom: 0">
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap">收入确认方式:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.confirmIncomeMethod_dictText }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="24">
        <a-table :columns="templateColumns" :data-source="templateDataList" bordered :pagination="false" size="small"
          :rowClassName="tableRowClass"></a-table>
      </a-col>
    </a-row>

    <p class="title" style="margin-top: 18px;" v-if="progressNodeVoList && progressNodeVoList.length">款项进度</p>
    <a-row type="flex" justify="center">
      <a-col :span="24" v-if="progressNodeVoList && progressNodeVoList.length">
        <a-table :columns="paymentProgressColumns" :data-source="progressNodeVoList" bordered :pagination="false"
          size="small" :rowClassName="tableRowClass"></a-table>
      </a-col>
      <!-- <a-col :span="12">
        <a-row>
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap" >履约保证金(元):</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.bail }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="12">
        <a-row>
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap" >应收日期:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.collectionDate }}</p>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="24">
        <a-row>
          <a-col style="display: flex;">
            <p style="margin-bottom: 0; white-space: nowrap" >款项节点说明:</p>
            <p style="margin:0 0 0 6px; word-break: break-all;">{{ formData.paymentDesc }}</p>
          </a-col>
        </a-row>
      </a-col> -->
    </a-row>

    <!-- 附件信息 -->
    <FileInfor :purchaseFile="purchaseFile" v-if="purchaseFile && purchaseFile.length" title="项目附件信息"></FileInfor>
    <FileInfor :purchaseFile="taskFile" v-if="taskFile && taskFile.length" title="任务附件信息"></FileInfor>
    <!-- 流程详情 -->
    <ProcessInfor v-if="formData.bpmStatus !== '1'" :dataHistorySource="dataHistorySource"></ProcessInfor>
  </div>
</template>
<script>
import { getAction } from '@/api/manage'
import FileInfor from '@/components/print/FileInfor.vue' // 审批历史流程列表组件
import ProcessInfor from '@/components/print/ProcessInfor.vue' // 审批历史流程列表组件
import address from '@/components/AddressChoice/address.js'
import { filterMultiDictText, initDictOptions } from '@/components/dict/JDictSelectUtil'
export default {
  props: {
    formBpm: {
      type: Boolean,
      default: false
    },
    formData: {
      type: Object,
      default: () => { },
      required: true
    },
    formDataHistory: {
      type: [Object, String],
      default: () => { },
      required: true
    }
  },
  components: {
    FileInfor,
    ProcessInfor
  },
  computed: {
    isShowProjectPay() {
      if (this.formData.expectWorkTime === null || this.formData.expectWorkTime === '' || this.formData.workCost === null || this.formData.workCost === '' || this.formData.outsourcingFee === null || this.formData.outsourcingFee === '' || this.formData.travelFee === null || this.formData.travelFee === '' || this.formData.professionReviewFee === null || this.formData.professionReviewFee === '' || this.formData.otherCost === null || this.formData.otherCost === '') {
        return false
      } else {
        return true
      }
    },
    // 判断是否为工程运维或者数字信息的业务分类
    isProjectInformation() {
      // 判断categoryName是否含有工程运维或者数字信息
      if (this.formData.categoryName && (this.formData.categoryName.indexOf('工程运维') !== -1 || this.formData.categoryName.indexOf('数字信息') !== -1)) {
        return true
      } else {
        return false
      }
    }
  },
  data() {
    return {
      address,
      filterMultiDictText,
      dictOptions: {},
      dataHistorySource: [], // 流程列表

      templateDataList: [], // 进度模板列表
      progressNodeVoList: [], // 款项进度列表

      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '项目成员',
          align: 'center',
          dataIndex: 'projectMember',
          customRender: (text, r) => {
            if (!text) {
              return ''
            } else {
              return filterMultiDictText(this.dictOptions['projectMember'], text + '')
            }
          }
        },
        {
          title: '分配合同额(元)',
          align: 'center',
          dataIndex: 'contractAmount'
        },
        {
          title: '合同额占比(%)',
          align: 'center',
          dataIndex: 'contractRate'
        },
        {
          title: '工时单价(元)',
          align: 'center',
          dataIndex: 'dayCost'
        },
        {
          title: '预算工时(小时)',
          align: 'center',
          dataIndex: 'expectWorkTime'
        }, {
          title: '项目绩效(元)',
          align: 'center',
          dataIndex: 'projectPerformance'
        },
        {
          title: '人工成本(元)',
          align: 'center',
          dataIndex: 'laborCost'
        }
      ],
      // 进度列表
      templateColumns: [
        {
          title: '顺序',
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '节点名称',
          align: 'center',
          dataIndex: 'nodeName'
        },
        {
          title: '节点进度(%)',
          align: 'center',
          dataIndex: 'nodeProgress',
          scopedSlots: { customRender: 'titleSlot' }
        },
        {
          title: '收入确认节点',
          align: 'center',
          dataIndex: 'isConfirmIncomeNode_dictText'
        }
      ],

      // 款项进度
      paymentProgressColumns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '款项名称',
          align: 'center',
          ellipsis: true,
          dataIndex: 'nodeName'
        },
        {
          title: '金额(元)',
          align: 'center',
          ellipsis: true,
          dataIndex: 'paymentMoney'
        },
        {
          title: '款项节点说明',
          align: 'center',
          ellipsis: true,
          dataIndex: 'nodeDesc'
        },
        // {
        //   title: '应收日期',
        //   align: 'center',
        //   ellipsis: true,
        //   dataIndex: 'collectionDate'
        // },
        // {
        //   title: '是否关联任务',
        //   align: 'center',
        //   ellipsis: true,
        //   customRender: (text) => {
        //     if (text === '' || text === null || text === undefined) {
        //       return ''
        //     } else {
        //       return text == 0 ? '否' : '是'
        //     }
        //   },
        //   dataIndex: 'isRelatedTask'
        // },
        // {
        //   title: '是否关联进度',
        //   align: 'center',
        //   ellipsis: true,
        //   customRender: (text) => {
        //     if (text === '' || text === null || text === undefined) {
        //       return ''
        //     } else {
        //       return text == 0 ? '否' : '是'
        //     }
        //   },
        //   dataIndex: 'isRelatedTaskNode'
        // },
        {
          title: '本任务关联款项金额(元)',
          align: 'center',
          ellipsis: true,
          dataIndex: 'taskPaymentMoney'
        },
        {
          title: '任务进度',
          align: 'center',
          ellipsis: true,
          dataIndex: 'taskNodeId_dictText'
        },
        {
          title: '节点进度(%)',
          align: 'center',
          ellipsis: true,
          dataIndex: 'taskProgress'
        }
      ],
      url: {
        historyList: '/api/erpmng/act/task/processHistoryList', // 流程历史跟踪接口
        queryByIds: '/api/erp/administration/seal/erpSealCertificationChangeRecord/queryByIds2', // 印章列表
        queryById: '/api/erp/omc/task/erpOmcTaskDistribution/queryById', // 獲取詳情
        erpOmcProjectQueryById: '/api/erp/omc/project/erpOmcProject/queryById',
        queryPageList: '/api/erp/omc/project/erpOmcProjectTaskFinal/queryPageList'
      },
      cust_lxr: 'erp_omc_customer_manager_contact,lxr,id,del_flag=0 and main_id=0',
      purchaseFile: [], // 附件
      taskFile: [], // 任务附件
      productBudgetFile: [], // 生产绩效表
      projectBudgetFile: [] // 项目预算表
    };
  },
  watch: {
    formData: {
      async handler(val) {
        if (val) {
          this.cust_lxr = await 'erp_omc_customer_manager_contact,lxr,id,del_flag=0 and main_id=\'' + val.ownerUnit + '\'';
          // 获取项目编号
          this.getProjectNumber(val.projectId)
          this.getMemberList(val.id)
          this.queryPaymentNodeListByMainId(val.id) // 获取款项进度列表
          this.queryTaskNodeListByMainId(val.id) // 获取任务进度列表
          this.getTaskNumber(val.taskId)
          this.initDictConfig() // 字典值
          if (val.attachment) {
            this.purchaseFile = val.attachment.split(',')
          } else {
            this.purchaseFile = []
          }
          if (val.taskFile) {
            this.taskFile = val.taskFile.split(',')
          } else {
            this.taskFile = []
          }
          if (val.projectBudgetFile) {
            this.projectBudgetFile = val.projectBudgetFile.split(',')
          } else {
            this.projectBudgetFile = []
          }
          if (val.productBudgetFile) {
            this.productBudgetFile = val.productBudgetFile.split(',')
          } else {
            this.productBudgetFile = []
          }
        }
      },
      immediate: true
    },
    formDataHistory: {
      handler(val) {
        if (val) {
          this.getHistoryList()
        }
      },
      immediate: true
    }
  },
  methods: {
    // 获取列表
    getHistoryList() {
      var params = { processInstanceId: this.formDataHistory.procInsId };// 查询条件
      getAction(this.url.historyList, params).then(res => {
        if (res.success) {
          this.dataHistorySource = res.result.records || res.result
        }
      })
    },

    // 获取项目数据
    getProjectNumber(projectId) {
      if (projectId) {
        getAction(this.url.erpOmcProjectQueryById, { id: projectId }).then((res) => {
          if (res.success) {
            var event = res.result
            this.$set(this.formData, 'finalNo', event.finalNo) // 项目编号
          }
        })
      }
    },
    // 获取子表
    getMemberList(mainId) {
      if (mainId) {
        getAction('/api/erp/omc/task/erpOmcTaskDistributionDt/list', { mainId }).then(response => {
          this.$set(this.formData, 'distributionDtList', response.result || [])
        })
      }
    },
    // 编辑获取款项进度列表
    queryPaymentNodeListByMainId(id) {
      if (!id) {
        return false
      }
      this.progressNodeVoLoading = true
      getAction('/api/erp/omc/task/erpOmcTaskDistribution/queryPaymentNodeListByMainId', { id }).then((res) => {
        if (res.success) {
          this.progressNodeVoList = res.result
        } else {
          this.queryPaymentListByProjectId(this.formData.taskId)
        }
      }).finally(() => {
        this.progressNodeVoLoading = false
      })
    },
    // 获取开始的款项进度列表
    queryPaymentListByProjectId(taskId, flag) {
      getAction('/api/erp/omc/task/erpOmcTaskDistribution/queryTaskPaymentList', { taskId }).then((res) => {
        if (res.success) {
          this.progressNodeVoList = res.result
        }
      })
    },
    // 编辑获取任务进度列表
    queryTaskNodeListByMainId(id) {
      if (!id) {
        return false
      }
      getAction('/api/erp/omc/task/erpOmcTaskDistribution/queryTaskNodeListByMainId', { id }).then((res) => {
        if (res.success) {
          this.templateDataList = res.result
        }
      })
    },
    // 获取项目数据
    getTaskNumber(taskId) {
      // // 获取任务编号
      if (taskId) {
        getAction(this.url.queryPageList, { id: taskId }).then((res) => {
          if (res.success) {
            if (res.result.records && res.result.records.length) {
              var event = res.result.records[0]
              this.$set(this.formData, 'taskNo', event.billNo) // 任务编号
            }
          }
        })
      }
    },

    initDictConfig() {
      // 人员名称
      initDictOptions('erp_employee_file,name,id').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'handlerId', res.result)
          this.$set(this.dictOptions, 'undertaker', res.result)
          this.$set(this.dictOptions, 'minister', res.result)
          this.$set(this.dictOptions, 'projectLeading', res.result)
          this.$set(this.dictOptions, 'approvalEngineer', res.result)
          this.$set(this.dictOptions, 'projectMember', res.result)
        }
      })
      initDictOptions('sys_user,realname,username').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'createBy', res.result)
        }
      })
      // 部门名称
      initDictOptions('sys_depart,depart_name,id').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'handlerDeptId', res.result)
          this.$set(this.dictOptions, 'executeDepart', res.result)
        }
      })
      initDictOptions('sys_depart,depart_name,org_code').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'sysOrgCode', res.result)
        }
      })
      // 团队名称
      initDictOptions('erp_omc_team_manager,alias_name,id').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'teamName', res.result)
          this.$set(this.dictOptions, 'productTeam', res.result)
        }
      })
      // 单位
      initDictOptions('erp_company_files,file_name,id').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'signUnit', res.result)
        }
      })
      // 业主单位
      initDictOptions('erp_purchase_supplier,enterprise_name,id').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'ownerUnit', res.result)
        }
      })
      // 联系人
      initDictOptions(this.cust_lxr).then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'contacts', res.result)
        }
      })
      // 项目来源
      initDictOptions('xmly_type').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'projectSource', res.result)
        }
      })
      // 任务类型
      initDictOptions('task_type').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'taskType', res.result)
        }
      })
      // 审批级别
      initDictOptions('approval_level').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'approvalLevel', res.result)
        }
      })
      // 行业类别
      initDictOptions('industry_category').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'industryCategory', res.result)
        }
      })
      // 复杂程度
      initDictOptions('industry_coefficient').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'complexity', res.result)
        }
      })
      // 是否出具报告
      initDictOptions('YES_OR_NO').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'isOutReport', res.result)
        }
      })
      // 是否出具报告
      initDictOptions('expense_accounting_method').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'expenseAccountingMethod', res.result)
        }
      })
    },

    // // 获取详情
    // detail() {
    //   // 根据ID查询
    //   getAction(this.url.queryById, { id: this.formData1.id }).then((res) => {
    //     if (res.success) {
    //       this.formData = { ...res.result, ...this.formData1 }
    //       this.initObj()
    //       if (res.result.upload) {
    //           this.purchaseFile = res.result.upload.split(',')
    //         }
    //     }
    //   })
    // },

    // 获取印章
    // initObj() {
    //   this.ids_dictText = '';
    //   if (this.formData.ids && this.formData.ids.length > 0) {
    //     // ids = ids.split(',');
    //     let url = '';
    //     let param = {};
    //     url = this.url.queryByIds;
    //     param = { ids: this.formData.ids };
    //     getAction(url, param).then((res) => {
    //       if (res.success) {
    //         this.dataSource = res.result // 印章列表
    //         if (res.result && res.result.length) {
    //           res.result.map((value, index) => {
    //             this.ids_dictText = value.sealType + ',' + this.ids_dictText
    //           })
    //           this.ids_dictText = this.ids_dictText.substr(0, this.ids_dictText.length - 1)
    //         }
    //       }
    //     });
    //   }
    // },

    getAddress(text) {
      if (!text) {
        return false
      }
      var areaList = text.split(',')
      var areaText = ''
      this.address.map(value => {
        if (areaList[0] && areaList[0] == value.code) {
          areaText = areaText + value.name + '/'
          if (value && value.children && value.children.length) {
            value.children.map(val => {
              if (areaList[1] && areaList[1] == val.code) {
                areaText = areaText + val.name + '/'

                if (val && val.children && val.children.length) {
                  val.children.map(va => {
                    if (areaList[2] && areaList[2] == va.code) {
                      areaText = areaText + va.name
                    }
                  })
                }
              }
            })
          }
        }
      })
      return areaText
    },

    tableRowClass(record, index) {
      if (index == 0) {
        return 'rowClass';
      }
      return ''
    }
  }
};
</script>
<style lang="less" scoped>
.page {
  background: #ffffff;
  padding: 19px 28px 0 28px;
  width: 750px;

  .print_title {
    font-size: 15px;
    font-family: Alibaba PuHuiTi 2.0;
    font-weight: normal;
    color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 9px;
  }

  .title {
    background: #EEEEEE;
    font-size: 13px;
    font-family: Alibaba PuHuiTi 2.0;
    font-weight: normal;
    color: #000000;
    padding: 11px 9px;
  }

  .content {
    font-size: 13px;
  }

  .title_table {
    font-size: 13px;
    font-family: Alibaba PuHuiTi 2.0;
    font-weight: normal;
    color: #000000;
  }
}

/deep/ .rowClass {
  font-size: 10px;
  font-family: Alibaba PuHuiTi 2.0;
  font-weight: normal;
  color: #000000;
}

/deep/ .ant-table-thead th {
  font-size: 10px;
  font-family: Alibaba PuHuiTi 2.0;
  font-weight: normal;
  color: #000000;
}

/deep/ .ant-table-thead tr {
  background: #EEEEEE;
}

/deep/ .ant-table-small>.ant-table-content>.ant-table-body {
  margin: 0 0px;
}

/deep/ .ant-table-body tr {
  font-size: 10px;
  font-family: Alibaba PuHuiTi 2.0;
  font-weight: normal;
  color: #000000;
}

/deep/ .ant-table-body tr td {
  word-wrap: break-word;
  word-break: break-all;
}

.content {
  font-size: 13px;
}
</style>
